package pers.fulsun.demo.springcloud.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

@Slf4j
@Configuration
public class ScheduleConfig {
    /**
     * 定时任务线程池对象
     *
     * @return
     */
    @Bean
    public ThreadPoolTaskScheduler threadPoolTaskScheduler() {
        ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
        //定时任务执行线程池核心线程数
        threadPoolTaskScheduler.setPoolSize(6);
        //允许移除任务
        threadPoolTaskScheduler.setRemoveOnCancelPolicy(true);
        //线程池前缀
        threadPoolTaskScheduler.setThreadNamePrefix("TestThread-");

        return threadPoolTaskScheduler;
    }

}
